<?php
  include "counter2.php";

  $join = '?';

pagestart();
?>
<html>
<?php pagehead(_("Places that do not use Linux")) ?>
<body bgcolor="white">
<?php pagetop(_("Countries that do not use Linux")) ?>

<?php print _("Here you can see the few countries from which not a single Linux user has registered as of") ?>
 <?php echo strftime("%a %b %d %H:%M:%S %Y %Z") ?>
<p>
<?php
  if (!$orderby = $counter->get_input('orderby', 'alpha', 'get')) {
  $orderby = 'name'; 
  }
?>
<?php
  if ($orderby == 'longname') {
      $desc = 'asc';
  } else {
      $desc = 'desc';
  }
#  print("SELECT name, longname, population FROM places
#  WHERE type = 'country' AND users = 0 ORDER BY ". $orderby .' '. $desc);
  $query = mysql_query("SELECT name, longname, population FROM places
  WHERE type = 'country' AND users = 0 ORDER BY ". $orderby .' '. $desc);
  if ($query == 0) {
      print "</table>" . _("MySQL error") . ": ". mysql_errno() .":". mysql_error();
      die('Query for count failed');
  }
  $rank = 1;
  while ($arr = mysql_fetch_array($query)) {
      if ($rank == 1) {
?>
<a name="table"></a>
<?php print _("The table is sorted by") ?>
 <?php
              print _($orderby);
?>
<table border=4>
   <tr>
       <th> # </th>
       <th><?php print _("ID") ?></th>
       <!-- note - RFC 2396 specifies that fragment follows query part -->
       <th><a href="<?php echo $_SERVER['PHP_SELF'].$join ?>orderby=longname#table"><?php print _("Place") ?></a></th>
       <th><a href="<?php echo $_SERVER['PHP_SELF'].$join ?>orderby=population#table"><?php print _("People") ?></a></th>
   </tr>
<?
      }
?>
   <tr align=right>
       <td><?php echo $rank; ?></td>
       <td align=left><?php echo $arr['name']; ?></td>
       <td align=left><a href="/reports/place.php?place=<?php
          echo urlencode($arr['name']);
          print "\">". $arr['longname'] ."</a>";
         ?>
       </td>
       <td><?php if ($arr['population'] >= 1) { printf("%6.1fM", $arr['population']); } elseif ($arr['population'] > 0) { printf("%6.0fK", $arr['population'] * 1000); } else { print _("Unknown"); } ?></td>
   </tr>
<?php
      ++$rank;
  }
  if ($rank > 1) {
      echo '</table>';
  }
  pagebottom();
?>
</body>
</html>
